fc17ac5a221ef3fecf641f2b51e7db456a89ef41,plugin/src/net/groboclown/idea/p4ic/v2/server/connection/AuthenticatedServer.java,AuthenticatedServer,authenticate,#,175

Before Change


    ServerAuthenticator.AuthenticationStatus authenticate()
            throws InterruptedException, P4JavaException {
        if (project != null && project.isDisposed()) {
            LOG.info("Can't authenticate: Project disposed for " + this);
            return ServerAuthenticator.DISPOSED;
        }
        if (server == null) {
            // The only place where this would matter is with the call to
            // ClientExec.ServerRunnerConnection.authenticate.  Even that
            // is called only when an unauthorized exception is called.
            // Other than that, this should always assume that it's connected.
            LOG.info("Can't authenticate: AuthenticatedServer is disposed for " + this);
            return ServerAuthenticator.DISPOSED;
        }

        if (invalidLoginStatus != null) {
            LOG.info("Previous login attempts failed.  Assuming authentication is invalid for " + this);
            return invalidLoginStatus;
        }

        ServerAuthenticator.AuthenticationStatus status = authenticator.discoverAuthenticationStatus(server);
        if (status.isAuthenticated()) {
            LOG.info("Server seems authenticated this " + this);
            return status;
        }
        if (status.isClientSetupProblem()) {
            LOG.info("Server has client setup problems for " + this);
            return status;
        }
        if (status.isNotConnected()) {
            // Could not connect.  Attempt to reconnect and retry the
            // authentication.  If it still fails to connect, then
            // report a problem (it may be a wrong port, or the server
            // could be down).
            LOG.info("Not connected to server; reconnecting for " + this);
            try {
                reconnect();
            } catch (URISyntaxException e) {
                return authenticator.createStatusFor(e);
            }
            status = authenticator.discoverAuthenticationStatus(server);
            if (status.isAuthenticated()) {
                LOG.info("Reconnected and seems authenticated for " + this);
                return status;
            }
            if (status.isNotConnected()) {
                LOG.info("Reconnected and still not connected for " + this);
                return status;
            }
            if (status.isClientSetupProblem()) {
                LOG.info("Reconnected and client setup problem for " + this);
                return status;
            }
            // Fall through to continue check.

After Change


    ServerAuthenticator.AuthenticationStatus authenticate()
            throws InterruptedException, P4JavaException {
        if (project != null && project.isDisposed()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Can't authenticate: Project disposed for " + this);
            }
            return ServerAuthenticator.DISPOSED;
        }
        if (server == null) {
            // The only place where this would matter is with the call to
            // ClientExec.ServerRunnerConnection.authenticate.  Even that
            // is called only when an unauthorized exception is called.
            // Other than that, this should always assume that it's connected.
            if (LOG.isDebugEnabled()) {
                LOG.debug("Can't authenticate: AuthenticatedServer is disposed for " + this);
            }
            return ServerAuthenticator.DISPOSED;
        }

        if (invalidLoginStatus != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Previous login attempts failed.  Assuming authentication is invalid for " + this);
            }
            return invalidLoginStatus;
        }

        ServerAuthenticator.AuthenticationStatus status = authenticator.discoverAuthenticationStatus(server);
        if (status.isAuthenticated()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Server seems authenticated this " + this);
            }
            return status;
        }
        if (status.isClientSetupProblem()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Server has client setup problems for " + this);
            }
            return status;
        }
        if (status.isNotConnected()) {
            // Could not connect.  Attempt to reconnect and retry the
            // authentication.  If it still fails to connect, then
            // report a problem (it may be a wrong port, or the server
            // could be down).
            if (LOG.isDebugEnabled()) {
                LOG.debug("Not connected to server; reconnecting for " + this);
            }
            try {
                reconnect();
            } catch (URISyntaxException e) {
                return authenticator.createStatusFor(e);
            }
            status = authenticator.discoverAuthenticationStatus(server);
            if (status.isAuthenticated()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Reconnected and seems authenticated for " + this);
                }
                return status;
            }
            if (status.isNotConnected()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Reconnected and still not connected for " + this);
                }
                return status;
            }
            if (status.isClientSetupProblem()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Reconnected and client setup problem for " + this);
                }
                return status;
            }